/*
 * Created by Jaren at 2021/8/20 15:28
 */
import 'dart:typed_data';

import 'package:encrypt/encrypt.dart';

class AesUtil {
    static encryptEcbNoPadding(Uint8ClampedList content, Uint8ClampedList pwd) {
        final encrypter = Encrypter(AES(Key(Uint8List.fromList(pwd.toList())), mode: AESMode.ecb, padding: null));
        return Uint8ClampedList.fromList(encrypter
            .encryptBytes(content, iv: IV.fromLength(16))
            .bytes);
    }

    static decryptEcbNoPadding(Uint8ClampedList content, Uint8ClampedList pwd) {
        final encrypter = Encrypter(AES(Key(Uint8List.fromList(pwd.toList())), mode: AESMode.ecb, padding: null));
        return Uint8ClampedList.fromList(encrypter.decryptBytes(Encrypted(Uint8List.fromList(content.toList())), iv: IV.fromLength(16)));
    }
}